package ${config.packageServiceImpl};

import ${config.packageEntity}.${tableInfo.javaName}${config.suffixEntity};
import ${config.packageMapper}.${tableInfo.javaName}${config.suffixMapper};
import ${config.packageService}.${tableInfo.javaName}${config.suffixService};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ${tableInfo.dbName}表Service实现类<#if tableInfo.comment?? && (tableInfo.comment?length>0)>, ${tableInfo.comment}</#if>
 *
 * @author ${config.author}
 * @date ${.now?string("yyyy-MM-dd HH:mm:ss")}
 */
@Service
public class ${tableInfo.javaName}${config.suffixServiceImpl} implements ${tableInfo.javaName}${config.suffixService} {
    @Autowired
    private ${tableInfo.javaName}${config.suffixMapper} ${utils.getLowerFirst(tableInfo.javaName)}${config.suffixMapper};

    @Override
    public void insert(${tableInfo.javaName}${config.suffixEntity} ${utils.getLowerFirst(tableInfo.javaName)}) {
        ${utils.getLowerFirst(tableInfo.javaName)}${config.suffixMapper}.insert(${utils.getLowerFirst(tableInfo.javaName)});
    }

    @Override
    public void update(${tableInfo.javaName}${config.suffixEntity} ${utils.getLowerFirst(tableInfo.javaName)}) {
        ${utils.getLowerFirst(tableInfo.javaName)}${config.suffixMapper}.update(${utils.getLowerFirst(tableInfo.javaName)});
    }

    @Override
    public List<${tableInfo.javaName}${config.suffixEntity}> findList(${tableInfo.javaName}${config.suffixEntity} ${utils.getLowerFirst(tableInfo.javaName)}){
        return ${utils.getLowerFirst(tableInfo.javaName)}${config.suffixMapper}.selectList(${utils.getLowerFirst(tableInfo.javaName)});
    }

    @Override
    public ${tableInfo.javaName}${config.suffixEntity} getBy${utils.getUpperCamel(tableInfo.primaryKey)}(<#list tableInfo.primaryKeyColumns as col>${utils.getSimpleTypeName(col.javaType)} ${col.javaName}<#if col?has_next>, </#if></#list>) {
        return ${utils.getLowerFirst(tableInfo.javaName)}${config.suffixMapper}.getBy${utils.getUpperCamel(tableInfo.primaryKey)}(<#list tableInfo.primaryKeyColumns as col>${col.javaName}<#if col?has_next>, </#if></#list>);
    }

}
